package cn.yutong.system.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import cn.yutong.framework.RestResponse;
import cn.yutong.system.entity.User;
import cn.yutong.system.service.IUserService;

/**
 * <p>
 * 系统用户表 前端控制器
 * </p>
 *
 * @author lnexin
 * @since 2018-11-26
 */
@RestController
@RequestMapping("/system/user")
public class UserController {
    @Autowired
    IUserService userService;


    @GetMapping("/{uid}")
    public RestResponse queryUserByUid(@PathVariable("uid") Integer userID) {
        User user = userService.selectById(userID);
        return user == null ? RestResponse.failure("查询失败") : RestResponse.success("查询用户信息成功", user);
    }


    @DeleteMapping("/{uid}")
    public RestResponse userDel(@PathVariable("uid") Integer userID) {
        boolean b = userService.deleteById(userID);
        return b ? RestResponse.success("删除用户成功") : RestResponse.failure("删除用户失败");
    }
}

